package com.yuwenchao.superafflatus.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yuwenchao.superafflatus.pojo.entity.SuperSalary;
import com.yuwenchao.superafflatus.mapper.SuperSalaryMapper;
import com.yuwenchao.superafflatus.pojo.vo.SuperSalaryVo;
import com.yuwenchao.superafflatus.service.SuperSalaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ChaooGG
 * @since 2021-05-31
 */
@Service
public class SuperSalaryServiceImpl extends ServiceImpl<SuperSalaryMapper, SuperSalary> implements SuperSalaryService {

    @Autowired
    SuperSalaryMapper superSalaryMapper;


    @Override
    public SuperSalaryVo getSalaryCount(String company) {

        return superSalaryMapper.getSalaryCount(company);
    }

    @Override
    public List<SuperSalary> getSalaryInfo(String start, String end,String company, Integer total) {
        List<SuperSalary> salaryInfo = superSalaryMapper.getSalaryInfo(start,end,company,total);

    if(CollUtil.isNotEmpty(salaryInfo)){
        return salaryInfo;
    }else{
        return  null;
    }

    }

    @Override
    public SuperSalaryVo getSalaryCountByYear(String start, String end) {

        return superSalaryMapper.getSalaryCountByYear(start,end);
    }

    @Override
    public boolean deleteSalaryInfoByMonth(String month) {
        QueryWrapper<SuperSalary> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("month",month);
        int delete = superSalaryMapper.delete(queryWrapper);
        boolean flag;
        if(delete>0){
            flag=true;
        }else{
            flag=false;
        }
        return flag;
    }

    @Override
    public SuperSalaryVo getSalaryCountBySumYear() {
        return superSalaryMapper.getSalaryCountBySumYear();
    }

    @Override
    public SuperSalaryVo getSalaryByYear(String year) {
        SuperSalaryVo salaryByYear = superSalaryMapper.getSalaryByYear(year);
            return salaryByYear;
    }

}
